package com.xtx.air.jcaptcha;

import com.jhlabs.image.WaterFilter;
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator;
import com.octo.captcha.component.image.color.SingleColorGenerator;
import com.octo.captcha.component.image.deformation.ImageDeformation;
import com.octo.captcha.component.image.deformation.ImageDeformationByFilters;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator;
import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.textpaster.textdecorator.BaffleTextDecorator;
import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.WordToImage;
import com.octo.captcha.component.word.FileDictionary;
import com.octo.captcha.component.word.wordgenerator.ComposeDictionaryWordGenerator;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.component.word.wordgenerator.WordGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.image.gimpy.GimpyFactory;

import java.awt.*;
import java.awt.image.ImageFilter;

/**
 * User: hanyi
 * Date: 12-2-12
 * Time: 下午11:05
 */
public class XtxGimpyEngine extends ListImageCaptchaEngine {
    @Override
    protected void buildInitialFactories() {

        WordGenerator wgen = new RandomWordGenerator("ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");

        TextPaster randomPaster = new DecoratedRandomTextPaster(new Integer(4), new Integer(5), new SingleColorGenerator(Color.black), new TextDecorator[]{new BaffleTextDecorator(new Integer(1), Color.white)});

        BackgroundGenerator back = new UniColorBackgroundGenerator(new Integer(80), new Integer(25), Color.white);

        FontGenerator shearedFont = new RandomFontGenerator(new Integer(12), new Integer(14), new Font[]{
                new Font("Arial", 0, 14),
                new Font("Tahoma", 0, 14),
                new Font("Verdana", 0, 14),
        }
        );

        WordToImage word2image = new ComposedWordToImage(shearedFont, back, randomPaster);

        addFactory(new GimpyIgnoreCaseFactory(wgen, word2image));
    }
}
